package com.cabrida.livestar.util;

import org.json.JSONObject;

import android.content.Context;

import com.cabrida.livestar.config.Global;

/**
 * 公共解析
 */
public class ComAnalysis {

	/**
	 * 解析保存user
	 */
	public static void analysisJSONUser(Context context, JSONObject response) {
		JSONObject data = JsonUtils.getJSONObject(response, "data",
				new JSONObject());
		String token = JsonUtils.getString(response, "token", "");

		Global.U_id = JsonUtils.getString(data, "udid", "");
		Global.S_name = JsonUtils.getString(data, "s_name", "");
		Global.U_balance = JsonUtils.getString(data, "u_balance", "");
		Global.U_sex = JsonUtils.getString(data, "u_sex", "");
		Global.U_age = JsonUtils.getString(data, "u_age", "");
		Global.U_city = JsonUtils.getString(data, "u_city", "");
		Global.U_nickname = JsonUtils.getString(data, "u_nickname", "");
		Global.U_type = JsonUtils.getString(data, "u_type", "");
		Global.U_token = token;
		Global.TIm_Sig = JsonUtils.getString(data, "tim", "");
		Global.headPic = JsonUtils.getString(data, "u_avatar", "");

		SharedUtils.putString(context, "U_id", Global.U_id);
		SharedUtils.putString(context, "S_name", Global.S_name);
		SharedUtils.putString(context, "U_nickname", Global.U_nickname);
		SharedUtils.putString(context, "U_balance", Global.U_balance);
		SharedUtils.putString(context, "U_type", Global.U_type);
		SharedUtils.putString(context, "U_token", Global.U_token);
		SharedUtils.putString(context, "TIm_Sig", Global.TIm_Sig);
		SharedUtils.putString(context, "headPic", Global.headPic);
		SharedUtils.putString(context, "U_sex", Global.U_sex);
		SharedUtils.putString(context, "U_age", Global.U_age);
		SharedUtils.putString(context, "U_city", Global.U_city);
	}
}
